/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nanosn.coffeemaker.server.urls;

/**
 * @see <a href="http://bitworking.org/projects/URI-Templates/">URI Template specification</a>
 * @author selkhateeb
 */
public class Patterns {

    private Pattern[] patterns;

    public Patterns(String packageName, Pattern... patterns) {
        this.patterns = patterns;

        if (packageName == null || packageName.trim().equals("")) {
            return;
        }

        for (Pattern pattern : patterns) {
            pattern.setPackageName(packageName);
        }
    }

    //Quick test
    public static void main(String[] args) {
        Patterns ps = new Patterns(null, new Pattern("/aa/{ere}", "test.Class.index"));
        for (Pattern pattern : ps.patterns) {
            System.out.println(pattern.getClassName());
        }
        ps = new Patterns(" ", new Pattern("/aa/{ere}", "test.Class.index"));
        for (Pattern pattern : ps.patterns) {
            System.out.println(pattern.getClassName());
        }
        ps = new Patterns("test.Class", new Pattern("/aa/{ere}", "index"));
        for (Pattern pattern : ps.patterns) {
            System.out.println(pattern.getClassName());
        }

    }

    public Pattern[] getPatterns() {
        return patterns;
    }
}
